package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResPicture;
import com.hmkj.entity.ErspSysMsg;

public class ErspSysMsgDao extends JActiveTable{
	public ErspSysMsgDao() {
		this.setDBTableName("ersp_sys_msg");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("msg_type", "msg_type", ActiveField.ftString, 11));
		AddField(new JActiveField("recv_userid", "recv_userid", ActiveField.ftString, 36));
		AddField(new JActiveField("msg_subject", "msg_subject", ActiveField.ftString, 500));
		AddField(new JActiveField("msg_content", "msg_content", ActiveField.ftString, 500));
		AddField(new JActiveField("msg_url", "msg_url", ActiveField.ftString, 500));
		AddField(new JActiveField("msg_isread", "msg_isread", ActiveField.ftString, 4));
		AddField(new JActiveField("msg_ispust", "msg_ispust", ActiveField.ftString, 4));
		AddField(new JActiveField("msg_isdelete", "msg_isdelete", ActiveField.ftString, 4));
		
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
        setDbKeyFields("id");
	}

	public int add(ErspSysMsg vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("msg_type", vo.getMsg_type());
		setFieldValue("recv_userid", vo.getRecv_userid());
		setFieldValue("msg_subject", vo.getMsg_subject());
		setFieldValue("msg_content", vo.getMsg_content());
		setFieldValue("msg_url", vo.getMsg_url());
		setFieldValue("msg_isread", vo.getMsg_isread());
		setFieldValue("msg_ispust", vo.getMsg_ispust());
		setFieldValue("msg_isdelete", vo.getMsg_isdelete());
		
		
		
		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspSysMsg vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("msg_type", vo.getMsg_type());
		setFieldValue("recv_userid", vo.getRecv_userid());
		setFieldValue("msg_subject", vo.getMsg_subject());
		setFieldValue("msg_content", vo.getMsg_content());
		setFieldValue("msg_url", vo.getMsg_url());
		setFieldValue("msg_isread", vo.getMsg_isread());
		setFieldValue("msg_ispust", vo.getMsg_ispust());
		setFieldValue("msg_isdelete", vo.getMsg_isdelete());
		
		return this.getSQL();
	}
}
